# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Alexsandr Pavlov <kidoz at mail dot ru>

_gemname=rack
pkgname=ruby-rack
pkgver=3.0.4.1
pkgrel=1
pkgdesc='Minimal, modular, and adaptable interface for developing web applications'
url='https://rack.github.io/'
arch=('any')
license=('MIT')
depends=('ruby')
makedepends=('ruby-rdoc' 'ruby-rake' 'ruby-bundler' 'ruby-minitest'
             'ruby-minitest-global_expectations' 'ruby-minitest-sprint')
checkdepends=('ruby-webrick')
options=('!emptydirs')
source=(https://github.com/rack/rack/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('024c48083f6f7251431724a1cbe90822605f599c17018c5c13ee1d6edfc58029')
sha512sums=('6cfb35d78901fdb5e7b4571eb6b37b035014cfea705aeff280a73930793e53cd6d2d9b51ae86803567884b5509af358c95687eecc222a5df61dc80d0ada019af')

prepare() {
  cd ${_gemname}-${pkgver}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec Rakefile
}

build() {
  cd ${_gemname}-${pkgver}
  rake build
}

check() {
  cd ${_gemname}-${pkgver}
  rake test
}

package() {
  cd ${_gemname}-${pkgver}
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}${_gemdir}" \
    -n "${pkgdir}/usr/bin" pkg/${_gemname}-${pkgver}.gem
  install -Dm 644 README.md CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 MIT-LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 example/* -t "${pkgdir}/usr/share/doc/${pkgname}/example"

  cd "${pkgdir}/${_gemdir}"
  rm -r "${pkgdir}/${_gemdir}/cache"
}

# vim: ts=2 sw=2 et:
